package com.google.gson.internal.bind;

import com.google.gson.b.a;
import com.google.gson.b.c;
import com.google.gson.b.d;
import com.google.gson.internal.ObjectConstructor;
import com.google.gson.q;
import java.io.IOException;
import java.util.Map;

public final class r extends TypeAdapter {
    final /* synthetic */ q a;
    private final ObjectConstructor b;
    private final Map c;

    private r(q qVar, ObjectConstructor objectConstructor, Map map) {
        this.a = qVar;
        this.b = objectConstructor;
        this.c = map;
    }

    public void a(d dVar, Object obj) throws IOException {
        if (obj == null) {
            dVar.f();
            return;
        }
        dVar.d();
        try {
            for (s sVar : this.c.values()) {
                if (sVar.h) {
                    dVar.a(sVar.g);
                    sVar.a(dVar, obj);
                }
            }
            dVar.e();
        } catch (IllegalAccessException e) {
            throw new AssertionError();
        }
    }

    public Object b(a aVar) throws IOException {
        if (aVar.f() == c.NULL) {
            aVar.j();
            return null;
        }
        Object construct = this.b.construct();
        try {
            aVar.c();
            while (aVar.e()) {
                s sVar = (s) this.c.get(aVar.g());
                if (sVar == null || !sVar.i) {
                    aVar.n();
                } else {
                    sVar.a(aVar, construct);
                }
            }
            aVar.d();
            return construct;
        } catch (Throwable e) {
            throw new q(e);
        } catch (IllegalAccessException e2) {
            throw new AssertionError(e2);
        }
    }
}
